package com.kaifamiao.strings;

/**
 * 1、boolean startsWith(String)
 * 2、boolean endsWith(String)
 * 3、boolean isEmpty()
 * 4、boolean isBlank()
 */
public class AssertString {

    public static void main(String[] args) {

        String filename = "kaifamiao_开发喵_明日战纪.mp4";

        String prefix = "kaifamiao";
        // 判断字符串是否以给定子串为前缀
        System.out.println( filename.startsWith( prefix ) );

        String suffix = ".mp4";
        // 判断字符串是否以给定子串为后缀
        System.out.println( filename.endsWith( suffix ) );

        // 判断字符串是否为空(即内部数组长度是否为零)
        System.out.println( filename.isEmpty() ); // JDK 1.6

        // 判断字符串是否为空白(即字符串是空串或仅由表示空白的字符组成)
        System.out.println( filename.isBlank() ); // JDK 11

        String empty = "";
        // String empty = new String();
        System.out.println( empty.isEmpty() ); // true

        String blank = " ";
        System.out.println( blank.isEmpty() ); // false
        System.out.println( blank.isBlank() ); // true

        blank = "\t";
        System.out.println( blank.isEmpty() ); // false
        System.out.println( blank.isBlank() ); // true

        blank = "\n";
        System.out.println( blank.isEmpty() ); // false
        System.out.println( blank.isBlank() ); // true

        blank = "";
        System.out.println( blank.isEmpty() ); // true
        System.out.println( blank.isBlank()); // true

    }

}
